package com.redsoft.epip;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.redsoft.spirit.dao.BaseRepositoryFactoryBean;
import com.redsoft.spirit.entity.JwtPatternUrl;
import com.redsoft.spirit.entity.JwtProperty;

@SpringBootApplication
// @EnableDiscoveryClient
// @EnableFeignClients
@EnableTransactionManagement // 启用事务
@EnableJpaRepositories(basePackages = { "com.redsoft" }, repositoryFactoryBeanClass = BaseRepositoryFactoryBean.class) // 指定自己的工厂类
@PropertySource("classpath:/config/jwt.properties")
@EnableConfigurationProperties({ JwtProperty.class, JwtPatternUrl.class }) // 加载自定义的properties解析类
@EntityScan("com.redsoft") // 扫描自己项目中的实体类，因为基础项目的包路径和
							// 实际项目的包路径不一样，所以就写前缀一样的。这样都扫描。
@ComponentScan("com.redsoft") // 扫描所有注解类，这个不加这个路径的话，默认会扫描本包名的，
// 就是com.redsoft.epip下的所有的，这样就无法触发到com.redsoft.spirit包下的了,作用和上面的实体类扫描一个意思
//@EnableCaching//启用缓存
public class EPIPApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(EPIPApplication.class);
	}

	public static void main(String[] args) throws InterruptedException {
		ApplicationContext ctx = SpringApplication.run(EPIPApplication.class, args);
	}

	// @Bean
	// public MethodValidationPostProcessor methodValidationPostProcessor(){
	// return new MethodValidationPostProcessor();
	// }

	// @Bean
	// public EmbeddedServletContainerCustomizer containerCustomizer() {
	//
	// return new EmbeddedServletContainerCustomizer() {
	// @Override
	// public void customize(ConfigurableEmbeddedServletContainer container) {
	//
	// ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED,
	// "/401.html");
	// ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND,
	// "/dist/index.html");
	// ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,
	// "/500.html");
	//
	// container.addErrorPages(error401Page, error404Page, error500Page);
	// }
	// };
	// }
}